package com.danicsoft.daide.historian;

import com.danicsoft.daide.token.TokenGroup;
import com.danicsoft.daide.token.TokenParser;

/**
 * Tracks errors in parsing tokens.
 * 
 * @author Daniel Yule (daniel.yule@gmail.com)
 * @version 1.0
 */
public class TokenHistorian extends BinaryHistorian {

	/**
	 * Construct a new TokenHistorian using a default console output.
	 */
	public TokenHistorian() {
		super();

	}

	/**
	 * Construct a new <code>TokenHistorian</code> using the given
	 * <code>Textbook</code> for output.
	 * 
	 * @param textbook
	 *        The textbook to output to.
	 */
	public TokenHistorian(Textbook textbook) {
		super(textbook);

	}
	
	/**
	 * Log a problem we've had with parsing the tokens.
	 * 
	 * @param parser
	 *        The TokenParser that generated the error.
	 * @param errorMessage
	 *        A description of the problem.
	 */
	public void logParsingProblem(TokenParser parser, String errorMessage) {
		logMessage(parser, "Problem parsing tokens: " + errorMessage, WARNING);
	}

	/**
	 * Logs a problem we've had parsing parenthesis.
	 * 
	 * @param parser
	 *        The parser that generated the problem.
	 * @param problemList
	 *        The list of tokens with unmatching parenthesis.
	 */
	public void logParenthesisProblem(TokenParser parser, @SuppressWarnings("unused")
	TokenGroup problemList) {
		logMessage(parser, "Found unmatched parenthesis", WARNING);
	}

	/**
	 * Log that we correctly parsed a message into tokens.
	 * 
	 * @param parser
	 *        The TokenParser that parsed the message.
	 * @param message
	 *        The message parsed.
	 */
	public void logMessageParsed(TokenParser parser, TokenGroup message) {
		logMessage(parser, "Parsed message: " + message, INFO);
	}

	/**
	 * Log that we have sent a message.
	 * @param parser The parser that sent the message.
	 * 
	 * @param message
	 *        The message we have sent.
	 */
	public void logMessageSent(TokenParser parser, TokenGroup message) {
		logMessage(parser, "Sent message: " + message, INFO);
	}

}
